﻿namespace HRM.CORE
{

    using APP.HELPER.Data.Helper;
    using System; using Extra.ERP;
    using System.ComponentModel;
    using System.Data;
    using System.Data.SqlClient;

    public class HRM_WORK
    {
        private DateTime m_BeginDate;
        private double m_Complete;
        private decimal m_Cost;
        private string m_Deliverer;
        private string m_DelivererName;
        private string m_Description;
        private string m_EmployeeCode;
        private string m_EmployeeName;
        private DateTime m_EndDate;
        private string m_Priority;
        private int m_Status;
        private string m_Work;
        private Guid m_WorkID;

        public HRM_WORK()
        {
            this.m_WorkID = Guid.Empty;
            this.m_EmployeeCode = "";
            this.m_EmployeeName = "";
            this.m_Deliverer = "";
            this.m_DelivererName = "";
            this.m_Work = "";
            this.m_Priority = "";
            this.m_BeginDate = DateTime.Now;
            this.m_EndDate = DateTime.Now;
            this.m_Status = 0;
            this.m_Complete = 0.0;
            this.m_Cost = 0M;
            this.m_Description = "";
        }

        public HRM_WORK(Guid WorkID, string EmployeeCode, string Deliverer, string Work, string Priority, DateTime BeginDate, DateTime EndDate, int Status, double Complete, decimal Cost, string Description)
        {
            this.m_WorkID = WorkID;
            this.m_EmployeeCode = EmployeeCode;
            this.m_Deliverer = Deliverer;
            this.m_Work = Work;
            this.m_Priority = Priority;
            this.m_BeginDate = BeginDate;
            this.m_EndDate = EndDate;
            this.m_Status = Status;
            this.m_Complete = Complete;
            this.m_Cost = Cost;
            this.m_Description = Description;
        }

        public string Delete()
        {
            string[] myParams = new string[] { "@WorkID" };
            object[] myValues = new object[] { this.m_WorkID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_WORK_Delete", myParams, myValues);
        }

        public string Delete(Guid WorkID)
        {
            string[] myParams = new string[] { "@WorkID" };
            object[] myValues = new object[] { WorkID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_WORK_Delete", myParams, myValues);
        }

        public string Delete(SqlConnection myConnection, Guid WorkID)
        {
            string[] myParams = new string[] { "@WorkID" };
            object[] myValues = new object[] { WorkID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_WORK_Delete", myParams, myValues);
        }

        public string Delete(SqlTransaction myTransaction, Guid WorkID)
        {
            string[] myParams = new string[] { "@WorkID" };
            object[] myValues = new object[] { WorkID };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_WORK_Delete", myParams, myValues);
        }

        public bool Exist(Guid WorkID)
        {
            bool hasRows = false;
            string[] myParams = new string[] { "@WorkID" };
            object[] myValues = new object[] { WorkID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_WORK_Get", myParams, myValues);
            if (reader != null)
            {
                hasRows = reader.HasRows;
                reader.Close();
                helper.Close();
                reader = null;
            }
            return hasRows;
        }

        public string Get(Guid WorkID)
        {
            string str = "";
            string[] myParams = new string[] { "@WorkID" };
            object[] myValues = new object[] { WorkID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader("HRM_WORK_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_WorkID = reader.GetGuid(reader.GetOrdinal("WorkID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_EmployeeName = Convert.ToString(reader["EmployeeName"]);
                    this.m_Deliverer = Convert.ToString(reader["Deliverer"]);
                    this.m_DelivererName = Convert.ToString(reader["DelivererName"]);
                    this.m_Work = Convert.ToString(reader["Work"]);
                    this.m_Priority = Convert.ToString(reader["Priority"]);
                    this.m_BeginDate = Convert.ToDateTime(reader["BeginDate"]);
                    this.m_EndDate = Convert.ToDateTime(reader["EndDate"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_Complete = Convert.ToDouble(reader["Complete"]);
                    this.m_Cost = Convert.ToDecimal(reader["Cost"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlConnection myConnection, Guid WorkID)
        {
            string str = "";
            string[] myParams = new string[] { "@WorkID" };
            object[] myValues = new object[] { WorkID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myConnection, "HRM_WORK_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_WorkID = reader.GetGuid(reader.GetOrdinal("WorkID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_EmployeeName = Convert.ToString(reader["EmployeeName"]);
                    this.m_Deliverer = Convert.ToString(reader["Deliverer"]);
                    this.m_DelivererName = Convert.ToString(reader["DelivererName"]);
                    this.m_Work = Convert.ToString(reader["Work"]);
                    this.m_Priority = Convert.ToString(reader["Priority"]);
                    this.m_BeginDate = Convert.ToDateTime(reader["BeginDate"]);
                    this.m_EndDate = Convert.ToDateTime(reader["EndDate"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_Complete = Convert.ToDouble(reader["Complete"]);
                    this.m_Cost = Convert.ToDecimal(reader["Cost"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public string Get(SqlTransaction myTransaction, Guid WorkID)
        {
            string str = "";
            string[] myParams = new string[] { "@WorkID" };
            object[] myValues = new object[] { WorkID };
            SqlHelper helper = new SqlHelper();
            SqlDataReader reader = helper.ExecuteReader(myTransaction, "HRM_WORK_Get", myParams, myValues);
            if (reader != null)
            {
                while (reader.Read())
                {
                    this.m_WorkID = reader.GetGuid(reader.GetOrdinal("WorkID"));
                    this.m_EmployeeCode = Convert.ToString(reader["EmployeeCode"]);
                    this.m_EmployeeName = Convert.ToString(reader["EmployeeName"]);
                    this.m_Deliverer = Convert.ToString(reader["Deliverer"]);
                    this.m_DelivererName = Convert.ToString(reader["DelivererName"]);
                    this.m_Work = Convert.ToString(reader["Work"]);
                    this.m_Priority = Convert.ToString(reader["Priority"]);
                    this.m_BeginDate = Convert.ToDateTime(reader["BeginDate"]);
                    this.m_EndDate = Convert.ToDateTime(reader["EndDate"]);
                    this.m_Status = Convert.ToInt32(reader["Status"]);
                    this.m_Complete = Convert.ToDouble(reader["Complete"]);
                    this.m_Cost = Convert.ToDecimal(reader["Cost"]);
                    this.m_Description = Convert.ToString(reader["Description"]);
                    str = "OK";
                }
                reader.Close();
                helper.Close();
                reader = null;
            }
            return str;
        }

        public DataTable GetList()
        {
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_WORK_GetList");
        }

        public DataTable GetListByDate(DateTime BeginDate, DateTime EndDate)
        {
            string[] myParams = new string[] { "@BeginDate", "@EndDate" };
            object[] myValues = new object[] { BeginDate, EndDate };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_WORK_GetListByDate", myParams, myValues);
        }

        public DataTable GetListByDateStatus(DateTime BeginDate, DateTime EndDate, int Status)
        {
            string[] myParams = new string[] { "@BeginDate", "@EndDate", "@Status" };
            object[] myValues = new object[] { BeginDate, EndDate, Status };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_WORK_GetListByDateStatus", myParams, myValues);
        }

        public DataTable GetListByEmployee(string EmployeeCode)
        {
            string[] myParams = new string[] { "@EmployeeCode" };
            object[] myValues = new object[] { EmployeeCode };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_WORK_GetListByEmployee", myParams, myValues);
        }

        public DataTable GetListByStatus(int Status)
        {
            string[] myParams = new string[] { "@Status" };
            object[] myValues = new object[] { Status };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteDataTable("HRM_WORK_GetListByStatus", myParams, myValues);
        }

        public string Insert()
        {
            string[] myParams = new string[] { "@WorkID", "@EmployeeCode", "@Deliverer", "@Work", "@Priority", "@BeginDate", "@EndDate", "@Status", "@Complete", "@Cost", "@Description" };
            object[] myValues = new object[] { this.m_WorkID, this.m_EmployeeCode, this.m_Deliverer, this.m_Work, this.m_Priority, this.m_BeginDate, this.m_EndDate, this.m_Status, this.m_Complete, this.m_Cost, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_WORK_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction)
        {
            string[] myParams = new string[] { "@WorkID", "@EmployeeCode", "@Deliverer", "@Work", "@Priority", "@BeginDate", "@EndDate", "@Status", "@Complete", "@Cost", "@Description" };
            object[] myValues = new object[] { this.m_WorkID, this.m_EmployeeCode, this.m_Deliverer, this.m_Work, this.m_Priority, this.m_BeginDate, this.m_EndDate, this.m_Status, this.m_Complete, this.m_Cost, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_WORK_Insert", myParams, myValues);
        }

        public string Insert(Guid WorkID, string EmployeeCode, string Deliverer, string Work, string Priority, DateTime BeginDate, DateTime EndDate, int Status, double Complete, decimal Cost, string Description)
        {
            string[] myParams = new string[] { "@WorkID", "@EmployeeCode", "@Deliverer", "@Work", "@Priority", "@BeginDate", "@EndDate", "@Status", "@Complete", "@Cost", "@Description" };
            object[] myValues = new object[] { WorkID, EmployeeCode, Deliverer, Work, Priority, BeginDate, EndDate, Status, Complete, Cost, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_WORK_Insert", myParams, myValues);
        }

        public string Insert(SqlConnection myConnection, Guid WorkID, string EmployeeCode, string Deliverer, string Work, string Priority, DateTime BeginDate, DateTime EndDate, int Status, double Complete, decimal Cost, string Description)
        {
            string[] myParams = new string[] { "@WorkID", "@EmployeeCode", "@Deliverer", "@Work", "@Priority", "@BeginDate", "@EndDate", "@Status", "@Complete", "@Cost", "@Description" };
            object[] myValues = new object[] { WorkID, EmployeeCode, Deliverer, Work, Priority, BeginDate, EndDate, Status, Complete, Cost, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_WORK_Insert", myParams, myValues);
        }

        public string Insert(SqlTransaction myTransaction, Guid WorkID, string EmployeeCode, string Deliverer, string Work, string Priority, DateTime BeginDate, DateTime EndDate, int Status, double Complete, decimal Cost, string Description)
        {
            string[] myParams = new string[] { "@WorkID", "@EmployeeCode", "@Deliverer", "@Work", "@Priority", "@BeginDate", "@EndDate", "@Status", "@Complete", "@Cost", "@Description" };
            object[] myValues = new object[] { WorkID, EmployeeCode, Deliverer, Work, Priority, BeginDate, EndDate, Status, Complete, Cost, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_WORK_Insert", myParams, myValues);
        }

        public string NewID()
        {
            return SqlHelper.GenCode("HRM_WORK", "WorkID", "Work");
        }

        public string Update()
        {
            string[] myParams = new string[] { "@WorkID", "@EmployeeCode", "@Deliverer", "@Work", "@Priority", "@BeginDate", "@EndDate", "@Status", "@Complete", "@Cost", "@Description" };
            object[] myValues = new object[] { this.m_WorkID, this.m_EmployeeCode, this.m_Deliverer, this.m_Work, this.m_Priority, this.m_BeginDate, this.m_EndDate, this.m_Status, this.m_Complete, this.m_Cost, this.m_Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_WORK_Update", myParams, myValues);
        }

        public string Update(Guid WorkID, string EmployeeCode, string Deliverer, string Work, string Priority, DateTime BeginDate, DateTime EndDate, int Status, double Complete, decimal Cost, string Description)
        {
            string[] myParams = new string[] { "@WorkID", "@EmployeeCode", "@Deliverer", "@Work", "@Priority", "@BeginDate", "@EndDate", "@Status", "@Complete", "@Cost", "@Description" };
            object[] myValues = new object[] { WorkID, EmployeeCode, Deliverer, Work, Priority, BeginDate, EndDate, Status, Complete, Cost, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery("HRM_WORK_Update", myParams, myValues);
        }

        public string Update(SqlConnection myConnection, Guid WorkID, string EmployeeCode, string Deliverer, string Work, string Priority, DateTime BeginDate, DateTime EndDate, int Status, double Complete, decimal Cost, string Description)
        {
            string[] myParams = new string[] { "@WorkID", "@EmployeeCode", "@Deliverer", "@Work", "@Priority", "@BeginDate", "@EndDate", "@Status", "@Complete", "@Cost", "@Description" };
            object[] myValues = new object[] { WorkID, EmployeeCode, Deliverer, Work, Priority, BeginDate, EndDate, Status, Complete, Cost, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myConnection, "HRM_WORK_Update", myParams, myValues);
        }

        public string Update(SqlTransaction myTransaction, Guid WorkID, string EmployeeCode, string Deliverer, string Work, string Priority, DateTime BeginDate, DateTime EndDate, int Status, double Complete, decimal Cost, string Description)
        {
            string[] myParams = new string[] { "@WorkID", "@EmployeeCode", "@Deliverer", "@Work", "@Priority", "@BeginDate", "@EndDate", "@Status", "@Complete", "@Cost", "@Description" };
            object[] myValues = new object[] { WorkID, EmployeeCode, Deliverer, Work, Priority, BeginDate, EndDate, Status, Complete, Cost, Description };
            SqlHelper helper = new SqlHelper();
            return helper.ExecuteNonQuery(myTransaction, "HRM_WORK_Update", myParams, myValues);
        }

        [Category("Column"), DisplayName("BeginDate")]
        public DateTime BeginDate
        {
            get
            {
                return this.m_BeginDate;
            }
            set
            {
                this.m_BeginDate = value;
            }
        }

        [DisplayName("Complete"), Category("Column")]
        public double Complete
        {
            get
            {
                return this.m_Complete;
            }
            set
            {
                this.m_Complete = value;
            }
        }

        [DisplayName("Cost"), Category("Column")]
        public decimal Cost
        {
            get
            {
                return this.m_Cost;
            }
            set
            {
                this.m_Cost = value;
            }
        }

        [Category("Column"), DisplayName("Deliverer")]
        public string Deliverer
        {
            get
            {
                return this.m_Deliverer;
            }
            set
            {
                this.m_Deliverer = value;
            }
        }

        [Category("Column"), DisplayName("DelivererName")]
        public string DelivererName
        {
            get
            {
                return this.m_DelivererName;
            }
            set
            {
                this.m_DelivererName = value;
            }
        }

        [DisplayName("Description"), Category("Column")]
        public string Description
        {
            get
            {
                return this.m_Description;
            }
            set
            {
                this.m_Description = value;
            }
        }

        [Category("Column"), DisplayName("EmployeeCode")]
        public string EmployeeCode
        {
            get
            {
                return this.m_EmployeeCode;
            }
            set
            {
                this.m_EmployeeCode = value;
            }
        }

        [DisplayName("EmployeeName"), Category("Column")]
        public string EmployeeName
        {
            get
            {
                return this.m_EmployeeName;
            }
            set
            {
                this.m_EmployeeName = value;
            }
        }

        [Category("Column"), DisplayName("EndDate")]
        public DateTime EndDate
        {
            get
            {
                return this.m_EndDate;
            }
            set
            {
                this.m_EndDate = value;
            }
        }

        [Category("Column"), DisplayName("Priority")]
        public string Priority
        {
            get
            {
                return this.m_Priority;
            }
            set
            {
                this.m_Priority = value;
            }
        }

        public string ProductName
        {
            get
            {
                return "Class HRM_WORK";
            }
        }

        public string ProductVersion
        {
            get
            {
                return "1.0.0.0";
            }
        }

        [Category("Column"), DisplayName("Status")]
        public int Status
        {
            get
            {
                return this.m_Status;
            }
            set
            {
                this.m_Status = value;
            }
        }

        [DisplayName("Work"), Category("Column")]
        public string Work
        {
            get
            {
                return this.m_Work;
            }
            set
            {
                this.m_Work = value;
            }
        }

        [Category("Primary Key"), DisplayName("WorkID")]
        public Guid WorkID
        {
            get
            {
                return this.m_WorkID;
            }
            set
            {
                this.m_WorkID = value;
            }
        }
    }
}

